package com.shop.cereshop.commons.enums;

import java.util.Objects;

/**
 * @description: 退款类型枚举类
 * @author zdd
 * @date 2025/9/24 21:25
 * @version 1.0
 */
public enum RefundTypeEnum {

    // 退款类型 (1:过期自动退款  2:用户主动退款)
    EXPIRED(1, "过期自动退款 "),
    USER_HANDLE(2, "用户主动退款");

    private Integer code;
    private String msg;

    private RefundTypeEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public static String getMsgByCode(Integer code) {
        if (Objects.isNull(code)) {
            return "";
        }
        RefundTypeEnum[] arr = RefundTypeEnum.values();
        for (int i = 0; i < arr.length; i++) {
            if (code.equals(arr[i].getCode())) {
                return arr[i].getMsg();
            }
        }
        return "";
    }
}
